#include "stdafx.h"
#include "NXRasterAPI.h"
#include "NXRasterInterior.h"
#include "OPENCLSupport.h"

CNXRaster* g_pRaster = NULL;

AFX_EXT_API BOOL NXInitSupport()
{
	g_pRaster = new CNXRaster;	
	return TRUE;
}

AFX_EXT_API BOOL NXRasterFigure( IN TPOUTLINEFIGURE* figure,IN CRect& rtRect, IN int& nWidth, IN int& nHeight, OUT float*& pBuffer )
{
	int nCount = GetTickCount();
	g_pRaster->RenderBuffer(figure,pBuffer,rtRect,nWidth,nHeight);
	nCount = GetTickCount() - nCount;
	TRACE(_T("%d \n"), nCount);
	return TRUE;
}

AFX_EXT_API BOOL NXReleaseCLSupport()
{
	delete g_pRaster;
	return TRUE;
}

AFX_EXT_API BOOL NXGetFigureLine( IN TPOUTLINEFIGURE* figure,OUT vector<NXLine>& vLine )
{
	g_pRaster->NXOutLineFigureConvert(figure,vLine);
	return TRUE;
}

AFX_EXT_API BOOL SetUseGPU( BOOL bUse )
{
	if (g_pRaster->m_bSupport)
	{
		g_pRaster->m_bUseGPU = bUse;
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

AFX_EXT_API BOOL NXRelease( IN OUT float*& pBuffer )
{
	delete[] pBuffer;
	return TRUE;
}

AFX_EXT_API BOOL NXRasterRotateFigure( IN TPOUTLINEFIGURE* figure, IN CRect& rtRect, IN int& nWidth, IN int& nHeight, IN float fRotate, IN POINTF ptTrans, IN float fScale, OUT float*& pBuffer )
{
	int nCount = GetTickCount();
	g_pRaster->RenderBufferTrans(figure,fRotate,ptTrans,fScale,pBuffer,rtRect,nWidth,nHeight);
	nCount = GetTickCount() - nCount;
	TRACE(_T("%d \n"), nCount);
	return TRUE;
}
